<template>
  <!-- 定制组件 -->
  <div class="customWidget">
    <div class="item" v-for="(item, index) in customWidgetList" :key="index" @mousedown="mousedown($event, item)"
      draggable="true">
      <!-- <span :class="item.icon"></span> -->
      <img :src="require('@/assets/icon/' + item.icon)">
      <p>{{ item.label }}</p>
    </div>
  </div>
</template>

<script>
export default {
  name: "customWidget",
  props: {
    customWidgetList: {//组件列表
      type: Array,
      required: true,
      default: () => []
    },
  },
  data() {
    return {}
  },
  methods: {
    // 鼠标按下事件(原生事件mousedown)
    mousedown(e, widget) {
      this.$emit('onWidgetMouseDown', e, widget)
    }
  },
}
</script>

<style lang="scss" scoped>
.customWidget {
  margin-top: 10px;

  .item {
    width: 60px;
    height: 100px;
    display: flex;
    align-items: center;
    flex-direction: column;
    font-size: 14px;
    text-align: center;
    color: #666;
    float: left;
    margin: 10px;
    margin-bottom: 0;
    border-radius: 6px;
    cursor: pointer;

    &:hover {
      background: #E6F0FE;
    }

    span {
      font-size: 50px;
      margin-bottom: 8px;
      color: #999;
    }

    p {
      margin: 0;
      font-size: 12px;
    }
  }
}
</style>